def skobki(s):
    c = []
    symbols = {")": "(", "}": "{", "]": "[", ">": "<"}
    for i in s:
        if i in symbols:
            top_element = c.pop() if c else '#'
            if symbols[i] != top_element:
                return False
        else:
            c.append(i)
    return not c

print(skobki(input()))